--- Python-2.7.10.org/Modules/_cursesmodule.c
+++ Python-2.7.10/Modules/_cursesmodule.c
@@ -113,11 +113,13 @@
 #define CURSES_MODULE
 #include "py_curses.h"
 
+#ifdef REAL_NCURSES
 /*  These prototypes are in <term.h>, but including this header
     #defines many common symbols (such as "lines") which breaks the
     curses module in other ways.  So the code will just specify
     explicit prototypes here. */
 extern int setupterm(char *,int,int *);
+#endif
 #ifdef __sgi
 #include <term.h>
 #endif
@@ -130,6 +132,10 @@
 #if defined(_AIX)
 #define STRICT_SYSV_CURSES
 #endif
+#ifndef REAL_NCURSES
+#include <termcap.h>
+#include <term.h>
+#endif
 
 /* Definition of exception curses.error */
 
@@ -312,7 +318,9 @@
 Window_NoArgNoReturnVoidFunction(wclear)
 
 Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)")
+#ifdef REAL_NCURSES
 Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)")
+#endif
 Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay")
 
 Window_NoArg2TupleReturnFunction(getyx, int, "ii")
@@ -336,7 +344,9 @@
 Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)")
 Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)")
 Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines")
+#ifdef REAL_NCURSES
 Window_OneArgNoReturnFunction(syncok, int, "i;True(1) or False(0)")
+#endif
 
 Window_TwoArgNoReturnFunction(mvwin, int, "ii;y,x")
 Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x")
@@ -806,7 +816,7 @@
         return NULL;
     }
 
-#ifdef WINDOW_HAS_FLAGS
+#if defined(WINDOW_HAS_FLAGS) && defined(REAL_NCURSES)
     if (self->win->_flags & _ISPAD)
         return PyCursesCheckERR(pechochar(self->win, ch | attr),
                                 "echochar");
@@ -1234,7 +1244,7 @@
     int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
     int rtn;
 
-#ifndef WINDOW_HAS_FLAGS
+#if !defined(WINDOW_HAS_FLAGS) || !defined(REAL_NCURSES)
     if (0)
 #else
         if (self->win->_flags & _ISPAD)
@@ -1377,7 +1387,7 @@
     int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
     int rtn;
 
-#ifndef WINDOW_HAS_FLAGS
+#if !defined(WINDOW_HAS_FLAGS) || !defined(REAL_NCURSES)
     if (0)
 #else
         if (self->win->_flags & _ISPAD)
@@ -1446,7 +1456,7 @@
     }
 
     /* printf("Subwin: %i %i %i %i   \n", nlines, ncols, begin_y, begin_x); */
-#ifdef WINDOW_HAS_FLAGS
+#if defined(WINDOW_HAS_FLAGS) && defined(REAL_NCURSES)
     if (self->win->_flags & _ISPAD)
         win = subpad(self->win, nlines, ncols, begin_y, begin_x);
     else
@@ -1580,7 +1590,9 @@
     {"hline",           (PyCFunction)PyCursesWindow_Hline, METH_VARARGS},
     {"idcok",           (PyCFunction)PyCursesWindow_idcok, METH_VARARGS},
     {"idlok",           (PyCFunction)PyCursesWindow_idlok, METH_VARARGS},
+#ifdef REAL_NCURSES
     {"immedok",         (PyCFunction)PyCursesWindow_immedok, METH_VARARGS},
+#endif
     {"inch",            (PyCFunction)PyCursesWindow_InCh, METH_VARARGS},
     {"insch",           (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS},
     {"insdelln",        (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS},
@@ -1618,7 +1630,9 @@
     {"subpad",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
     {"subwin",          (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS},
     {"syncdown",        (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS},
+#ifdef REAL_NCURSES
     {"syncok",          (PyCFunction)PyCursesWindow_syncok, METH_VARARGS},
+#endif
     {"syncup",          (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS},
     {"timeout",         (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS},
     {"touchline",       (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS},
@@ -1680,10 +1694,10 @@
 
 NoArgReturnIntFunction(baudrate)
 NoArgReturnIntFunction(termattrs)
-
+#ifdef REAL_NCURSES
 NoArgReturnStringFunction(termname)
 NoArgReturnStringFunction(longname)
-
+#endif
 NoArgTrueFalseFunction(can_change_color)
 NoArgTrueFalseFunction(has_colors)
 NoArgTrueFalseFunction(has_ic)
@@ -1697,7 +1711,9 @@
 {
     /* not checking for PyCursesInitialised here since filter() must
        be called before initscr() */
+#ifdef REAL_NCURSES
     filter();
+#endif
     Py_INCREF(Py_None);
     return Py_None;
 }
@@ -1780,7 +1796,11 @@
 
     PyCursesInitialised;
 
+#ifdef REAL_NCURSES
     getsyx(y, x);
+#else
+    x=-1; y=-1;
+#endif
 
     return Py_BuildValue("(ii)", y, x);
 }
@@ -1855,7 +1875,7 @@
     return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
 }
 
-#ifndef STRICT_SYSV_CURSES
+#if !defined(STRICT_SYSV_CURSES) && defined(REAL_NCURSES)
 /* No has_key! */
 static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
 {
@@ -2383,16 +2403,16 @@
 static PyObject *
 PyCurses_ResizeTerm(PyObject *self, PyObject *args)
 {
-    int lines;
-    int columns;
+    int linez;
+    int columnz;
     PyObject *result;
 
     PyCursesInitialised;
 
-    if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns))
+    if (!PyArg_ParseTuple(args,"ii:resizeterm", &linez, &columnz))
         return NULL;
 
-    result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
+    result = PyCursesCheckERR(resizeterm(linez, columnz), "resizeterm");
     if (!result)
         return NULL;
     if (!update_lines_cols())
@@ -2425,6 +2445,7 @@
 }
 #endif /* HAVE_CURSES_RESIZE_TERM */
 
+#ifdef REAL_NCURSES
 static PyObject *
 PyCurses_setsyx(PyObject *self, PyObject *args)
 {
@@ -2444,6 +2465,7 @@
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 static PyObject *
 PyCurses_Start_Color(PyObject *self)
@@ -2546,8 +2568,11 @@
     PyCursesInitialised;
 
     if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL;
-
+#ifdef REAL_NCURSES
     return PyCursesCheckERR(typeahead( fd ), "typeahead");
+#else
+    return PyCursesCheckERR(ERR, "typeahead");
+#endif
 }
 
 static PyObject *
@@ -2608,7 +2633,9 @@
         PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument");
         return NULL;
     }
+#ifdef REAL_NCURSES
     use_env(flag);
+#endif
     Py_INCREF(Py_None);
     return Py_None;
 }
@@ -2662,7 +2689,7 @@
     {"has_colors",          (PyCFunction)PyCurses_has_colors, METH_NOARGS},
     {"has_ic",              (PyCFunction)PyCurses_has_ic, METH_NOARGS},
     {"has_il",              (PyCFunction)PyCurses_has_il, METH_NOARGS},
-#ifndef STRICT_SYSV_CURSES
+#if defined(REAL_NCURSES) && !defined(STRICT_SYSV_CURSES)
     {"has_key",             (PyCFunction)PyCurses_has_key, METH_VARARGS},
 #endif
     {"halfdelay",           (PyCFunction)PyCurses_HalfDelay, METH_VARARGS},
@@ -2678,7 +2705,9 @@
     {"keyname",             (PyCFunction)PyCurses_KeyName, METH_VARARGS},
 #endif
     {"killchar",            (PyCFunction)PyCurses_KillChar, METH_NOARGS},
+#ifdef REAL_NCURSES
     {"longname",            (PyCFunction)PyCurses_longname, METH_NOARGS},
+#endif
     {"meta",                (PyCFunction)PyCurses_Meta, METH_VARARGS},
 #ifdef NCURSES_MOUSE_VERSION
     {"mouseinterval",       (PyCFunction)PyCurses_MouseInterval, METH_VARARGS},
@@ -2708,12 +2737,16 @@
     {"resize_term",         (PyCFunction)PyCurses_Resize_Term, METH_VARARGS},
 #endif
     {"savetty",             (PyCFunction)PyCurses_savetty, METH_NOARGS},
+#ifdef REAL_NCURSES
     {"setsyx",              (PyCFunction)PyCurses_setsyx, METH_VARARGS},
+#endif
     {"setupterm",           (PyCFunction)PyCurses_setupterm,
      METH_VARARGS|METH_KEYWORDS},
     {"start_color",         (PyCFunction)PyCurses_Start_Color, METH_NOARGS},
     {"termattrs",           (PyCFunction)PyCurses_termattrs, METH_NOARGS},
+#ifdef REAL_NCURSES
     {"termname",            (PyCFunction)PyCurses_termname, METH_NOARGS},
+#endif
     {"tigetflag",           (PyCFunction)PyCurses_tigetflag, METH_VARARGS},
     {"tigetnum",            (PyCFunction)PyCurses_tigetnum, METH_VARARGS},
     {"tigetstr",            (PyCFunction)PyCurses_tigetstr, METH_VARARGS},
